package com.kuang.myRule;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRule {
    //注意自定义的负载均衡不可以和主启动类写在同一级目录，不然启动时会被扫描，有异常
    @Bean
    public IRule myRule(){
        //return new RandomRule();
        return new MyRandomRule(); //使用自定义负载均衡的算法
    }
}
